/*
*	全国三级城市联动 js版
*	author:		mrasong
*	homepage:	http://asong.us/
*	E-mail:		mrasong#163.com
*	version:	1.0.2
*	data:		tencent
**/
function Dsy(){
	this.Items = {};
}
Dsy.prototype.add = function(id,iArray){
	this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id){
	if(typeof(this.Items[id]) == "undefined") return false;
	return true;
}

function change(v){
	var str="0";
	for(i=0;i<v;i++){
		str+=("_"+(document.getElementById(s[i]).selectedIndex-1));
	};
	var ss=document.getElementById(s[v]);
	with(ss){
		length = 0;
		options[0]=new Option(opt0[v],opt0[v]);
		if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v){
			if(dsy.Exists(str)){
				ar = dsy.Items[str];
				for(i=0;i<ar.length;i++){
					options[length]=new Option(ar[i],ar[i]);
				}//end for
				if(v){ options[0].selected = true; }
			}
		}//end if v
		if(++v<s.length){change(v);}
	}//End with
}

var dsy = new Dsy();

dsy.add("0",["江苏省"]);
//苏锡常
dsy.add("0_0_0",["钟楼区","天宁区","戚墅堰区","新北区","武进区","金坛市","溧阳市"]);
dsy.add("0_0_1",["崇安区","南长区","北塘区","滨湖区","惠山区","锡山区","江阴市","宜兴市"]);
dsy.add("0_0_2",["金阊区","沧浪区","平江区","虎丘区","吴中区","相城区","吴江市","昆山市","太仓市","常熟市","张家港市"]);
dsy.add("0_0",["常州市","无锡市","苏州市"]);
dsy.add("0",["江苏省"]);

var s=["s_province","s_city","s_county"];//三个select的name
var opt0 = ["省份","地级市","市、县级市"];//初始值
function _init_area(){  //初始化函数
	for(i=0;i<s.length-1;i++){
	  document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
	}
	change(0);
}
